programming4us
           
 
 
Sharepoint

SharePoint 2010 : Adding a user via PowerShell, Delegating PowerShell permissions

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
7/10/2013 7:31:21 PM

1. Adding a user via PowerShell

When SharePoint is initially set up, many users may need to be added to SharePoint groups for a new site. The quickest and most efficient way to accomplish this is through PowerShell and scripting.

The following recipe shows how to add a user to a SharePoint group via PowerShell.

Getting ready

The user must have access to one of the servers running PowerShell 2.0 and be a member of the WSS_ADMIN_WPG on the local computer. You must also be a member of the SharePoint_Shell_Access role&; on the configuration database (SQL Role).

There must be an existing site, a SharePoint group called TestAddUser, and a user named jdoe set up in the active directory.

How to do it...

  1. Click on the Start button on the web front end.

  2. Under All Programs, navigate to the Microsoft SharePoint 2010 Products folder.

  3. Right-click on the SharePoint 2010 Management Shell option and click Run as Administrator. The PowerShell console will appear.

  4. Type the following command into the console window, replacing the parameter values with ones that are relevant to your environment:

    New-spuser -web http://sitename -useralias "PZSjdoe" -group "TestAddUser"
    
  5. The result of the operation is shown here:

How it works...

Using PowerShell with SharePoint, the Microsoft.SharePoint.PowerShell snapin must be added using the Add-PSSnapin cmdlet&;. This is done automatically when you use the SharePoint 2010 Management Shell.

PowerShell is integrated with the .NET framework. SharePoint exposes its management capability to PowerShell. The SharePoint object model is also available via PowerShell. The power of PowerShell is the ability to script commands together. These commands are referred to as cmdlets.

Cmdlets follow a <verb> <noun> naming pattern&;.

There's more...

The following PowerShell commands provide users with management functionality:

  • Get-SPUser&;: Returns a user after matching the record with the provided criteria. The common criteria are user identity and website where they are a user.

  • Remove-SPUser: Deletes a user from a site.&;

  • Move-SPUser: Moves a user account into the provided site.

  • Set-SPUser: Configuration of user properties.

More info

You can combine several cmdlets together to create a script, saving the file with a .ps1 extension. The script could reference a file containing a list of active directory user accounts. This will allow you to do a batch upload of the users to the designated sites and groups.

2. Delegating PowerShell permissions

One of the many promises SharePoint 2010 delivers on is the empowering of users. In other words, SharePoint 2010 allows an administrator to delegate responsibility down to the other administrative user. The concern with doing this is exposing other administrative tasks. Just because someone can manage an application, such as Search, does not mean they should be able to manage other service applications. SharePoint 2010 handles this without putting at risk the security of the other components. Farm Administrators can designate users to manage their own service application. This is done through the management UI of each service application. Taking this management one step further, a Farm Administrator can designate a user with the ability to run PowerShell commands against their particular service(s) from their own machines.

The least privileged account model in SharePoint has been taken to another level. Users have access to manage only what you, as an administrator, have designated to them.

This recipe will show how to grant PowerShell access to a user so that they can manage their service applications.

Getting ready

You must have farm-level administrative permissions. A user must be set up in the active directory — the recipe will use the domain \jdoe. Replace domain with the appropriate value from your installation.

You will need the name of the service application database to which you are assigning rights. You can get this with the help of the following PowerShell command:

GetSPServiceApplication-SPServiceApplication

How to do it...

  1. Click on the Start button on the web front end server.

  2. Under All Programs, navigate to the Microsoft SharePoint 2010 Products folder.

  3. Right-click on the SharePoint 2010 Management Shell option and click Run as Administrator. The PowerShell console will appear.

  4. Type the following command into the console window:

    Add-SPShellAdmin -username domain\jdoe
    

    Press the Enter key.

  5. Type the following into the console window, replacing the parameter values with ones relevant to your environment:

    Add-SPShellAdmin -username domain\jdoe -database 047e05eb-2d68-46a1-b0e0-e9ac92e99ff8
    
    
    					  

    Press the Enter key again.

How it works...

The first command did the following two things:

  • It added the user to the SharePoint_Shell_Access role&; in the farm configuration database. If the role was not in the database, it is created automatically. When the user is added, the role grants the users, db_owner as well as securityadmin, with the rights to the farm configuration database.

  • It added the user to the WSS_ADMIN_WPG local security group&; on each server in the farm.

The second command added the parameter named database. We targeted a specific content database (using its GUID in this case) and the user was added to the SharePoint_Shell_Access role for that database. Additionally, the user is added to the role in the Central Administration content database.

There's more...

Using PowerShell, an administrator can obtain a list of names that are part of the SharePoint_Shell_Access role&;, with the help of the following command:

Get-SPShellAdmin

More info

The most effective use of PowerShell is in regards to scripting. Actions can be automated. Automation comes in the guise of writing code. Combine this statement with the type of access that is granted in this recipe — db_owner. This should not be granted without any thought, for example, power users should not be conferred with so much authority.

A typical power user cannot write, and should not be authorized to write code, in order to automate things such as uploading a Term Set to the managed metadata service. On top of that, a power user should not be granted the db_owner access as is shown in this recipe.

Note that PowerShell does not do security trimming. When a user is given this ability on a database, they have db_owner access to everything in that database.

However, the administrator of the farm may not have time to automate functions. A Farm Administrator can delegate this responsibility to the appropriate person who has the ability to write the PowerShell code. That person can be granted ownership of the service.

Anyone who has the capability must understand the code and, even more importantly, the ramifications of their script with regards to the topology of the farm. For instance, if a developer is granted db_owner access to a content database that houses several site collections, the developer now has full access to all the site collections in the content database.
Other -----------------
- SharePoint Server 2010 Business Intelligence Platform (part 6) - Reporting Services
- SharePoint Server 2010 Business Intelligence Platform (part 5) - PowerPivot
- SharePoint Server 2010 Business Intelligence Platform (part 4) - PerformancePoint Services - Time Intelligence, Decomposition Tree
- SharePoint Server 2010 Business Intelligence Platform (part 3) - PerformancePoint Services - Create a Dashboard
- SharePoint Server 2010 Business Intelligence Platform (part 2) - PerformancePoint Services - Using PerformancePoint Within a Site, Dashboard Designer, PerformancePoint Data Connections
- SharePoint Server 2010 Business Intelligence Platform (part 1) - Business Intelligence Web Parts
- SharePoint 2010 : Writing Workflows with Visual Studio
- SharePoint 2010 : Writing Workflows with SharePoint Designer
- SharePoint 2010 : Customizing Out of the Box Workflows
- SharePoint 2010 : Out of the Box Workflows
- SharePoint 2010 : Office 2010 Client Applications (part 4)
- SharePoint 2010 : Office 2010 Client Applications (part 3) - Backstage
- SharePoint 2010 : Office 2010 Client Applications (part 2) - Documents and Data Caching
- SharePoint 2010 : Office 2010 Client Applications (part 1)
- Sharepoint 2010 : Content Management - In place Records Management
- Sharepoint 2010 : Content Management - Importing a Term Set
- Sharepoint 2010 : Content Management - Creating a Term Set
- Sharepoint 2010 : Content Management - Managing External Content Types
- Sharepoint 2010 : Content Management - Adding a Content Type hub
- SharePoint 2010 : Content Management - Configuring content deployment
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us